<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <title>微赢智能信息管理系统</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <!-- VENDOR CSS -->
    <link rel="stylesheet" th:href="@{/assets/vendor/bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/font-awesome/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/linearicons/style.css}">
    <link rel="stylesheet" th:href="@{/assets/vendor/chartist/css/chartist-custom.css}">
    <!-- MAIN CSS -->
    <link rel="stylesheet" th:href="@{/assets/css/main.css}">
    <!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
    <link rel="stylesheet" th:href="@{/assets/css/demo.css}">
    <!-- ICONS -->
    <link rel="apple-touch-icon" sizes="76x76" th:href="@{/assets/img/apple-icon.png}">
    <link rel="icon" type="image/png" sizes="96x96" th:href="@{/assets/img/favicon.png}">
    <script th:src="@{/assets/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/assets/vendor/bootstrap/js/bootstrap.min.js}"></script>
    <script th:src="@{/assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
    <script th:src="@{/assets/vendor/jquery.easy-pie-chart/jquery.easypiechart.min.js}"></script>
    <script th:src="@{/assets/vendor/chartist/js/chartist.min.js}"></script>
    <script th:src="@{/assets/scripts/klorofil-common.js}"></script>
</head>
<body>
<!-- WRAPPER -->
<div id="wrapper">
    <!-- NAVBAR -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="brand">
            <a href="index.html"><img th:src="@{/assets/img/logo-dark.png}" alt="Klorofil Logo"
                                      class="img-responsive logo"></a>
        </div>
        <div class="container-fluid">
            <div class="navbar-btn">
                <button type="button" class="btn-toggle-fullwidth"><i class="lnr lnr-arrow-left-circle"></i></button>
            </div>
            <div id="navbar-menu">
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><img th:src="@{/assets/img/user.png}"
                                                                                        class="img-circle" alt="Avatar">
                            <span th:text="${session.loginSysUserName}">Samuel</span> <i
                                    class="icon-submenu lnr lnr-chevron-down"></i></a>
                        <ul class="dropdown-menu">
                            <li><a th:href="@{/logout}"><i class="lnr lnr-exit"></i> <span>退出</span></a></li>
                        </ul>
                    </li>
                    <!-- <li>
                        <a class="update-pro" href="#downloads/klorofil-pro-bootstrap-admin-dashboard-template/?utm_source=klorofil&utm_medium=template&utm_campaign=KlorofilPro" title="Upgrade to Pro" target="_blank"><i class="fa fa-rocket"></i> <span>UPGRADE TO PRO</span></a>
                    </li> -->
                </ul>
            </div>
        </div>
    </nav>
    <!-- END NAVBAR -->
    <!-- LEFT SIDEBAR -->
    <div id="sidebar-nav" class="sidebar">
        <div class="sidebar-scroll">
            <nav>
                <ul class="nav">
                    <shiro:hasPermission name="jggl">
                        <li>
                            <a href="#subPages1" data-toggle="collapse" class="collapsed "><i
                                    class="lnr lnr-apartment"></i>
                                <span>机构管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages1" class="collapse">
                                <ul class="nav">
                                    <shiro:hasPermission name="jgxxgl">
                                        <li><a th:href="@{/hospital}">
                                            <span>机构信息管理</span></a>
                                        </li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="tp">
                                        <li><a th:href="@{/images}" class=""> <span>图片</span></a>
                                        </li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="jgflgl">
                                        <li><a th:href="@{/hospitalField}" class="">
                                            <span>机构分类管理</span></a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="bmgl">
                                        <li><a th:href="@{/hospitalDepartment}" class="">
                                            <span>部门管理</span></a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="jgjjgl">
                                        <li><a th:href="@{/hospitalProfile}" class="">
                                            <span>机构简介管理</span></a></li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="qxgl">
                        <li><a th:href="@{/hospitalPermission}" class=""><i class="lnr lnr-inbox"></i>
                            <span>权限管理</span></a></li>
                    </shiro:hasPermission>
                    <!--  <li><a th:href="@{/user}" class=""><i class="lnr lnr-users"></i>
                          <span>用户管理</span></a></li>-->
                    <shiro:hasPermission name="zjgl">
                        <li>
                            <a href="#subPages" data-toggle="collapse" class="collapsed"><i
                                    class="lnr lnr-graduation-hat"></i>
                                <span>专家管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages" class="collapse ">
                                <ul class="nav">
                                    <shiro:hasPermission name="zjxxgl">
                                        <li><a th:href="@{/master}" class="">专家信息管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="zjdtmx">
                                        <li><a th:href="@{/masterScore}" class="">专家答题明细</a>
                                        </li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="wtgl">
                        <li><a th:href="@{/question}" class=""><i class="lnr lnr-menu-circle"></i>
                            <span>问题管理</span></a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="hmd">
                        <li><a th:href="@{/blackList}" class=""><i class="lnr lnr-sad"></i> <span>黑名单</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="dd">
                        <li><a th:href="@{/wxOrder}" class=""><i class="lnr lnr-list"></i> <span>订单</span></a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="yhhdgl">
                        <li><a th:href="@{/hospitalActivity}" class=""><i class="lnr lnr-star"></i>
                            <span>优惠活动管理</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="ztjz">
                        <li><a th:href="@{/knowledge}" class=""><i class="lnr lnr-diamond"></i> <span>专题讲座</span></a>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="yygl">
                        <li>
                            <a href="#subPages2" data-toggle="collapse" class="collapsed"><i
                                    class="lnr lnr-pencil"></i>
                                <span>预约管理</span> <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            <div id="subPages2" class="collapse ">
                                <ul class="nav">
                                    <shiro:hasPermission name="yyslgl">
                                        <li><a th:href="@{/guahao}" class="">预约数量管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="xxgl">
                                        <li><a th:href="@{/hospitalSchedule}" class="">信息管理</a></li>
                                    </shiro:hasPermission>
                                    <shiro:hasPermission name="lscx">
                                        <li><a th:href="@{/guahaoHistory}" class="">历史查询</a>
                                        </li>
                                    </shiro:hasPermission>
                                </ul>
                            </div>
                        </li>
                    </shiro:hasPermission>
                </ul>
            </nav>
        </div>
    </div>
    <!-- END LEFT SIDEBAR -->
    <!-- MAIN -->
    <div class="main">
        <div class="main-content">
            <div class="container-fluid">
                <div class="row">
                    <form id="search-form" class="form-inline" role="form" th:action="@{/searchImg}" method="post"
                    >
                        <div class="form-group">
                            <label>选择机构名称</label>
                            <select id="hospitalName" name="hospitalName" class="form-control">
                                <option th:each="hospitals : ${hospitals}"
                                        th:value="${hospitals.name}" th:text="${hospitals.name}">
                                </option>
                            </select>
                        </div>
                        <button id="btn-search" type="submit"
                                class="btn btn-info btn-sm rightSize">
                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>搜索
                        </button>
                    </form>
                    <button id="btn-add" type="button"
                            class="btn btn-info btn-sm rightSize" onclick="addImgModel()">
                        <span class="glyphicon glyphicon-search" aria-hidden="true"></span>添加
                    </button>
                </div>
                <h2 th:text="${hospital.name}"></h2>
                <!-- MAIN CONTENT -->
                <div class="row" style="margin-top: 10px">
                    <div class="col-sm-6 col-md-4" th:each="hospitalImg :${hospitalImg}">
                        <div class="thumbnail" id="img-content">
                            <img th:src="@{{path}(path=${hospitalImg.imgUrl})}"
                                 style="width: 300px;height: 200px;">
                            <div class="caption">
                                <h3>图片</h3>
                            </div>
                            <div>
                                <form role="form" th:id="${hospitalImg.id}" th:action="@{/updateMasterHeadImg}"
                                      method="post"
                                      enctype="multipart/form-data">
                                    <div class="form-group" style="display: none">
                                        <input type="text" id="imgId" name="imgId" th:value="${hospitalImg.id}">
                                    </div>
                                    <div class="form-group">
                                        <input type="file" name="file">
                                    </div>
                                </form>
                                <button type="button" class="btn btn-primary"
                                        th:onclick="'uploadImgModel(\''+${hospitalImg.id}+'\');'">替换
                                </button>
                                <button type="button" class="btn btn-danger"
                                        th:onclick="'deleteImgModel(\''+${hospitalImg.id}+'\');'">删除
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- END MAIN -->
        </div>
    </div>
    <div class="modal fade" id="addImgModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">添加机构图片</h4>
                </div>
                <div class="modal-body">
                    <form role="form" id="addHospitalImgForm">
                        <div class="form-group">
                            <label>选择机构名称</label>
                            <select id="hospitalNameImg" name="hospitalNameImg" class="form-control">
                                <option th:each="hospitals : ${hospitals}"
                                        th:value="${hospitals.name}" th:text="${hospitals.name}">
                                </option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>选择图片上传</label>
                            <input type="file" name="imgFile">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="addHospitalImgModel()">提交更改</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
</div>
<div class="modal fade" id="model1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center"><h2>确定要删除所选图片？</h2></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="deleteImg()">确定</button>
                <button type="button" class="btn btn-default" onclick="modelhide1()">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="model2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center"><h2>确定要替换图片？</h2></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="uploadImg()">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" id="model3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: center"><h2>确定要添加图片？</h2></div>
            <div class="modal-footer">
                <button type="button" id="addHospitalImgBtn" class="btn btn-primary" onclick="addHospitalImg()">确定
                </button>
                <button type="button" id="closeaddHospitalImgBtn" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<div class="modal fade" style="left: 50%;top: 50%;transform: translate(-50%,-50%);" id="loadingModel" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 100px; ">
        <div class="modal-content">
            <div class="modal-body" style="vertical-align: middle;text-align: center;">
                <img th:src="@{/assets/img/loadingcircle.gif}">
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<footer>
    <div class="container-fluid">
        <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=37078602370880"
           style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img
                th:src="@{/assets/img/beian.png}" style="float:left;"/>
            <p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">鲁公网安备
                37078602370880号</p></a>
    </div>
</footer>
<!-- END WRAPPER -->
<!-- Javascript -->
<script th:inline="javascript">
    var deleteImgId;
    var uploadImgId;
    function uploadImg() {
        $('#model2').modal('hide');
        $.ajax({
            url: '/fenda/uploadImg',
            type: 'POST',
            cache: false,
            data: new FormData($('#' + uploadImgId)[0]),
            processData: false,
            contentType: false,
            beforeSend: function () {
                $("#loadingModel").modal({backdrop: 'static', keyboard: false});
            },
            complete: function () {
                $("#loadingModel").modal('hide');
                $(".modal-backdrop").remove();
            }
        }).done(function (res) {
            location.reload(true);
        }).fail(function (res) {
        });
    }
    function uploadImgModel(uploadId) {
        uploadImgId = uploadId;
        $('#model2').modal({
            keyboard: true
        });
    }
    function addImgModel() {
        $('#addImgModel').modal({
            keyboard: true
        })
    }
    function addHospitalImg() {
        $.ajax({
            url: '/fenda/addHospitalImg',
            type: 'POST',
            cache: false,
            data: new FormData($("#addHospitalImgForm")[0]),
            processData: false,
            contentType: false,
            beforeSend: function () {
                $("#model3").hide();
                $("#addImgModel").hide();
                $("#loadingModel").modal({backdrop: 'static', keyboard: false});
            },
            complete: function () {
                $("#loadingModel").modal('hide');
                $(".modal-backdrop").remove();
            }
        }).done(function (res) {
            location.reload(true);
        }).fail(function (res) {
        });
    }
    function addHospitalImgModel() {
        $('#model3').modal({keyboard: true})
    }
    function deleteImgModel(imgId) {
        deleteImgId = imgId;
        $('#model1').modal({
            keyboard: true
        });
    }
    function deleteImg() {
        $('#model1').modal('hide');
        $.ajax({
            url: "/fenda/deleteImg",
            data: {
                deleteHospitalImgId: deleteImgId
            },
            type: "post",
            beforeSend: function () {
                $("#loadingModel").modal({backdrop: 'static', keyboard: false});
            },
            complete: function () {
                $("#loadingModel").modal('hide');
                $(".modal-backdrop").remove();
            },
            success: function () {
                location.reload(true);
            }
        });
    }
    function modelhide1() {
        $('#model1').modal('hide');
    }
</script>
</body>
</html>
